<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/8/18 0018
 * Time: 17:35
 */
namespace app\index\controller;

use app\index\model\Clents;

class Client extends Publiccom
{
    public function index()
    {
        $phone = input('get.phone');
        $pageParam = ['query' =>[]];
        $back = new Clents();
        if ($phone){
            $count = count($back -> where('phone',$phone) -> select());
            $back->where('phone', $phone);
            $pageParam['query']['phone'] = $phone;
            $tick = $back -> order('id desc') ->where('phone',$phone)-> paginate(20,$count,$pageParam);
        }else{
            $count = count($back -> select());
            $tick = $back -> order('id desc') -> paginate(20,$count,$pageParam);
        }
        $this -> assign('list',$tick);
        return view();
    }
    public function del()
    {
        $phone = input('get.id');
        $del = db('clents') -> where('id',$phone) ->delete();
        if ($del){
            return 0;
        }else{
            return 2;
        }
    }
}